home *** CD-ROM | disk | FTP | other *** search
/ Chip 1996 November / CHIP Kasım 1996.iso / ms / visualj / vjtrialb.exe / RCDATA / CABINET / MFCAPWZ.DLL / TEMPLATE / DOC.CPP < prev    next >
C/C++ Source or Header  |  1996-07-31  |  5KB  |  204 lines

  1. // $$doc_ifile$$.cpp : implementation of the $$DOC_CLASS$$ class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "$$root$$.h"
  6.  
  7. $$IF(CRecordView || CDaoRecordView)
  8. #include "$$recset_hfile$$.h"
  9. $$ENDIF
  10. #include "$$doc_hfile$$.h"
  11. $$IF(CONTAINER || CONTAINER_SERVER)
  12. #include "$$cntritem_hfile$$.h"
  13. $$ENDIF
  14. $$IF(MINI_SERVER || FULL_SERVER || CONTAINER_SERVER)
  15. #include "$$srvritem_hfile$$.h"
  16. $$ENDIF
  17.  
  18. #ifdef _DEBUG
  19. #define new DEBUG_NEW
  20. #undef THIS_FILE
  21. static char THIS_FILE[] = __FILE__;
  22. #endif
  23.  
  24. /////////////////////////////////////////////////////////////////////////////
  25. // $$DOC_CLASS$$
  26.  
  27. IMPLEMENT_DYNCREATE($$DOC_CLASS$$, $$DOC_BASE_CLASS$$)
  28.  
  29. BEGIN_MESSAGE_MAP($$DOC_CLASS$$, $$DOC_BASE_CLASS$$)
  30.     //{{AFX_MSG_MAP($$DOC_CLASS$$)
  31. $$IF(VERBOSE)
  32.         // NOTE - the ClassWizard will add and remove mapping macros here.
  33.         //    DO NOT EDIT what you see in these blocks of generated code!
  34. $$ENDIF
  35.     //}}AFX_MSG_MAP
  36. $$IF(CONTAINER || CONTAINER_SERVER)
  37.     // Enable default OLE container implementation
  38. $$IF(!CRichEditView)
  39.     ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE, $$DOC_BASE_CLASS$$::OnUpdatePasteMenu)
  40.     ON_UPDATE_COMMAND_UI(ID_EDIT_PASTE_LINK, $$DOC_BASE_CLASS$$::OnUpdatePasteLinkMenu)
  41.     ON_UPDATE_COMMAND_UI(ID_OLE_EDIT_CONVERT, $$DOC_BASE_CLASS$$::OnUpdateObjectVerbMenu)
  42.     ON_COMMAND(ID_OLE_EDIT_CONVERT, $$DOC_BASE_CLASS$$::OnEditConvert)
  43. $$ENDIF //!CRichEditView
  44.     ON_UPDATE_COMMAND_UI(ID_OLE_EDIT_LINKS, $$DOC_BASE_CLASS$$::OnUpdateEditLinksMenu)
  45.     ON_COMMAND(ID_OLE_EDIT_LINKS, $$DOC_BASE_CLASS$$::OnEditLinks)
  46.     ON_UPDATE_COMMAND_UI(ID_OLE_VERB_FIRST, $$DOC_BASE_CLASS$$::OnUpdateObjectVerbMenu)
  47. $$ENDIF
  48. $$IF(MAPI)
  49.     ON_COMMAND(ID_FILE_SEND_MAIL, OnFileSendMail)
  50.     ON_UPDATE_COMMAND_UI(ID_FILE_SEND_MAIL, OnUpdateFileSendMail)
  51. $$ENDIF //MAPI
  52. END_MESSAGE_MAP()
  53.  
  54. $$IF(AUTOMATION)
  55. BEGIN_DISPATCH_MAP($$DOC_CLASS$$, $$DOC_BASE_CLASS$$)
  56.     //{{AFX_DISPATCH_MAP($$DOC_CLASS$$)
  57.         // NOTE - the ClassWizard will add and remove mapping macros here.
  58.         //      DO NOT EDIT what you see in these blocks of generated code!
  59.     //}}AFX_DISPATCH_MAP
  60. END_DISPATCH_MAP()
  61.  
  62. $$IF(VERBOSE)
  63. // Note: we add support for IID_I$$Doc$$ to support typesafe binding
  64. //  from VBA.  This IID must match the GUID that is attached to the 
  65. //  dispinterface in the .ODL file.
  66.  
  67. // {$$DISPIID_CLSID_ODL$$}
  68. $$ENDIF //VERBOSE
  69. static const IID IID_I$$Doc$$ =
  70. $$DISPIID_CLSID$$;
  71.  
  72. BEGIN_INTERFACE_MAP($$DOC_CLASS$$, $$DOC_BASE_CLASS$$)
  73.     INTERFACE_PART($$DOC_CLASS$$, IID_I$$Doc$$, Dispatch)
  74. END_INTERFACE_MAP()
  75.  
  76. $$ENDIF //AUTOMATION
  77. /////////////////////////////////////////////////////////////////////////////
  78. // $$DOC_CLASS$$ construction/destruction
  79.  
  80. $$DOC_CLASS$$::$$DOC_CLASS$$()
  81. {
  82. $$IF(COMPFILE)
  83. $$IF(VERBOSE)
  84.     // Use OLE compound files
  85. $$ENDIF
  86.     EnableCompoundFile();
  87.  
  88. $$ENDIF //COMPFILE
  89. $$IF(VERBOSE)
  90.     // TODO: add one-time construction code here
  91.  
  92. $$ENDIF
  93. $$IF(AUTOMATION)
  94.     EnableAutomation();
  95.  
  96.     AfxOleLockApp();
  97. $$ENDIF
  98. }
  99.  
  100. $$DOC_CLASS$$::~$$DOC_CLASS$$()
  101. {
  102. $$IF(AUTOMATION)
  103.     AfxOleUnlockApp();
  104. $$ENDIF
  105. }
  106.  
  107. BOOL $$DOC_CLASS$$::OnNewDocument()
  108. {
  109.     if (!$$DOC_BASE_CLASS$$::OnNewDocument())
  110.         return FALSE;
  111. $$IF(PROJTYPE_SDI)
  112. $$IF(CEditView)
  113.  
  114.     ((CEditView*)m_viewList.GetHead())->SetWindowText(NULL);
  115. $$ENDIF //CEditView
  116. $$ENDIF //PROJTYPE_SDI
  117.  
  118. $$IF(VERBOSE)
  119.     // TODO: add reinitialization code here
  120.     // (SDI documents will reuse this document)
  121.  
  122. $$ENDIF
  123.     return TRUE;
  124. }
  125. $$IF(CRichEditView)
  126.  
  127. $$CNTRITEM_BASE_CLASS$$* $$DOC_CLASS$$::CreateClientItem(REOBJECT* preo) const
  128. {
  129.     // cast away constness of this
  130.     return new $$CNTRITEM_CLASS$$(preo, ($$DOC_CLASS$$*) this);
  131. }
  132. $$ENDIF //CRichEditView
  133. $$IF(MINI_SERVER || FULL_SERVER || CONTAINER_SERVER)
  134.  
  135. /////////////////////////////////////////////////////////////////////////////
  136. // $$DOC_CLASS$$ server implementation
  137.  
  138. COleServerItem* $$DOC_CLASS$$::OnGetEmbeddedItem()
  139. {
  140. $$IF(VERBOSE)
  141.     // OnGetEmbeddedItem is called by the framework to get the COleServerItem
  142.     //  that is associated with the document.  It is only called when necessary.
  143.  
  144. $$ENDIF
  145.     $$SRVRITEM_CLASS$$* pItem = new $$SRVRITEM_CLASS$$(this);
  146.     ASSERT_VALID(pItem);
  147.     return pItem;
  148. }
  149. $$ENDIF
  150. $$IF(!DB_NO_FILE)
  151.  
  152. /////////////////////////////////////////////////////////////////////////////
  153. // $$DOC_CLASS$$ serialization
  154.  
  155. void $$DOC_CLASS$$::Serialize(CArchive& ar)
  156. {
  157. $$IF(CEditView)
  158. $$IF(VERBOSE)
  159.     // CEditView contains an edit control which handles all serialization
  160. $$ENDIF //VERBOSE
  161.     ((CEditView*)m_viewList.GetHead())->SerializeRaw(ar);
  162. $$ELSE
  163.     if (ar.IsStoring())
  164.     {
  165. $$IF(VERBOSE)
  166.         // TODO: add storing code here
  167. $$ENDIF
  168.     }
  169.     else
  170.     {
  171. $$IF(VERBOSE)
  172.         // TODO: add loading code here
  173. $$ENDIF
  174.     }
  175. $$IF(CONTAINER || CONTAINER_SERVER)
  176. $$IF(VERBOSE)
  177.  
  178.     // Calling the base class $$DOC_BASE_CLASS$$ enables serialization
  179.     //  of the container document's COleClientItem objects.
  180. $$ENDIF
  181.     $$DOC_BASE_CLASS$$::Serialize(ar);
  182. $$ENDIF
  183. $$ENDIF //CEditView
  184. }
  185. $$ENDIF //!DB_NO_FILE
  186.  
  187. /////////////////////////////////////////////////////////////////////////////
  188. // $$DOC_CLASS$$ diagnostics
  189.  
  190. #ifdef _DEBUG
  191. void $$DOC_CLASS$$::AssertValid() const
  192. {
  193.     $$DOC_BASE_CLASS$$::AssertValid();
  194. }
  195.  
  196. void $$DOC_CLASS$$::Dump(CDumpContext& dc) const
  197. {
  198.     $$DOC_BASE_CLASS$$::Dump(dc);
  199. }
  200. #endif //_DEBUG
  201.  
  202. /////////////////////////////////////////////////////////////////////////////
  203. // $$DOC_CLASS$$ commands
  204.